package com.example.musicdemo.widget

import android.content.Context
import android.text.format.Formatter
import android.util.AttributeSet
import android.view.View
import android.widget.RelativeLayout
import android.widget.TextView
import com.example.musicdemo.R
import com.example.musicdemo.model.Music
import kotlinx.android.synthetic.main.item_vbang.view.*

class VBangItemView : RelativeLayout {
    lateinit var tvLetter :TextView

    constructor(context: Context?) : super(context)
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) :
            super(context, attrs, defStyleAttr)
    init {
        View.inflate(context, R.layout.item_vbang,this)
        tvLetter = findViewById(R.id.catalog)
    }

    fun setData(itemBean: Music){
        //歌曲名字
        title.text = itemBean.name
        artist.text = itemBean.ar?.get(0)?.name
        //歌曲大小
        size.text = Formatter.formatFileSize(context,itemBean.size)

    }



}